import java.util.ArrayList;

public class Opinion {
  public static String PUNCTUATION_REGEXP = "\\p{Punct}+";
  public static String WHITESPACE_REGEXP = "\\s";

  int value_;

  String pre_;
  String post_;
  String sent_;
  String opholder_;
  double conf_;
  ArrayList<String> topics_;

  Opinion(int value, String pre, String post, String sent) {
    value_ = value;
    pre_ = pre;
    post_ = post;
    sent_ = sent;
    opholder_ = "";
    conf_ = 0.0;
    topics_ = new ArrayList<String>();
  }
  
  public double getConfidence() {
    return conf_;
  }
  
  public void setConfidence(String c) {
    conf_ = Double.parseDouble(c);
  }

  public void setOpinionHolder(String oph) {
    opholder_ = oph;
  }

  public String getOpinionHolder() {
    return opholder_;
  }

  public boolean matchesWithAuthor(String author) {
    String tempOph = new String(opholder_);
    String tempAuth = new String(author);

    // tempOph = tempOph.replaceAll(PUNCTUATION_REGEXP, "");
    // tempAuth = tempAuth.replaceAll(PUNCTUATION_REGEXP, "");
    //
    // tempOph = tempOph.replaceAll(WHITESPACE_REGEXP, "");
    // tempAuth = tempAuth.replaceAll(WHITESPACE_REGEXP, "");
    tempOph = tempOph.replaceAll("[^a-zA-Z]", "");
    tempAuth = tempAuth.replaceAll("[^a-zA-Z]", "");

    return tempOph.equalsIgnoreCase(tempAuth);
  }

  public boolean isUnknownOpinionHolder() {
    return opholder_.equals("Unknown");
  }

  public int getPolarity() {
    return value_;
  }

  public String getPreSentence() {
    return pre_;
  }

  public String getPostSentence() {
    return post_;
  }

  public String getSentence() {
    return sent_;
  }
  
  public void setTopics(ArrayList<String> topics) {
    topics_ = topics;
  }
  
  public ArrayList<String> getTopics() {
    return topics_;
  }
}